﻿using Architecture.Api.Application.Command.UserCommand;
using Architecture.Domain.RBAC;
using Architecture.Service;
using MediatR;

namespace Architecture.Api.Application.CommandHandlers.UserHandler
{
    public class UserUpdateCommandHandler : IRequestHandler<UserUpdateCommand, int>
    {
        private readonly IUserService _userService;

        public UserUpdateCommandHandler(IUserService userService)
        {
            _userService = userService;
        }

        public async Task<int> Handle(UserUpdateCommand request, CancellationToken cancellationToken)
        {
            return await _userService.UpdateAsync(new UserInfo()
            {
                UserId = request.UserId,
                UserName = request.UserName,
                UserSex = request.UserSex,
                UserAddress = request.UserAddress,
                ProvinceId = request.ProvinceId,
                UrbanId = request.UrbanId,
                CountyId = request.CountyId,
                AddName = request.AddName,
                AddTime = request.AddTime,
            });
        }
    }
}
